<script setup lang="ts">
import { AssetsItem, PanLayout, usePanState } from "./provider";
import { List, Grid } from "@element-plus/icons-vue";

const state = usePanState();
const { selectedAssets, layout } = state;

const onAssetBreadcrumbClick = (item: AssetsItem) => {
  console.log(item);
};
</script>

<template>
  <div class="pan-contain-head">
    <el-breadcrumb>
      <el-breadcrumb-item>
        <el-button text>全部</el-button>
      </el-breadcrumb-item>
      <el-breadcrumb-item v-for="asset in selectedAssets" :key="asset.getKey()">
        <el-button text @click="onAssetBreadcrumbClick(asset)">{{
          asset.getTitle()
        }}</el-button>
      </el-breadcrumb-item>
    </el-breadcrumb>
    <el-space>
      <el-segmented
        v-model="layout"
        :options="[
          { label: '列表', value: PanLayout.List, icon: List },
          { label: '网格', value: PanLayout.Grid, icon: Grid }
        ]"
      >
        <template #default="scope">
          <el-icon :size="15">
            <component :is="scope.item.icon" />
          </el-icon>
        </template>
      </el-segmented>
    </el-space>
  </div>
</template>
<style lang="scss" scoped>
.pan-contain-head {
  height: 100%;
  width: 100%;
  align-items: center;
  display: flex;
  justify-content: space-between;
  border-bottom: 1px solid #e8e8e8;
}
</style>
